package com.powernode.mybatis.web;

import com.powernode.mybatis.service.AccountService;
import com.powernode.mybatis.service.impl.AccountServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * author 金宇廷的星空
 * version 1.0
 * date  2023/4/10 17:27
 * poject Mybatis
 */
@WebServlet("/transfer")
public class AccountServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //获取表单数据
        String fromActno = request.getParameter("fromActno");
        String toActno = request.getParameter("toActno");
        String money = request.getParameter("money");
        double vmoney = Double.parseDouble(money);
        //调用service
        AccountService accountService = new AccountServiceImpl();
        accountService.transfer(fromActno,toActno,vmoney);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
    }
}
